home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
PredatorPrey
/
calc_files.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-22
|
22KB
|
898 lines
/* look at this */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
/* */
/* Prototype HP15C Calculator */
/* James C. Ullrey */
/* INRESCO */
/* © 1990 */
/* Version 13.97a */
/* */
/* FILE SEGMENT */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
#define jcuNewOrigin FALSE /*TRUE*/
/*****************************************************************/
/* I N C L U D E S */
/*****************************************************************/
#ifndef __C14__
#include "PredatorPrey.h"
#endif
#include "Globals.h"
#include <Lists.h>
#include <Resources.h>
#include "PredatorPreyData.h"
#include "calc_files.h"
#include "ResourceDefs.h"
#include "calc_dipshit.h"
#include "Miscellany.h"
/********************************************************************
/* G L O B A L V A R I A B L E D E C L A R A T I O N S
/********************************************************************/
extern Boolean newCreated;
extern Boolean preRegistered;
extern WindowPtr gMy_windows[];
extern long gState;
extern long gsState;
extern long sto;
extern long rcl;
/*extern long gNewNum;*/
/*extern long canClear;*/
/*extern long gRoll;*/
extern long wait;
extern long gFlag;
extern long fFlag;
extern long sWait;
extern long rWait;
extern long lblWait;
extern long plus;
extern long minus;
extern long timesF;
extern long divide;
extern long gDot;
/*extern long rsFlag;*/
extern long gDigits;
/*extern long runMode;*/
/*extern long gsbWait;*/
extern long gtoWait;
//extern short sRefNum; /* Log file 2 */
//extern short rRefNum; /* Log file 1 */
extern short qRefNum; /* map data */
extern short pRefNum;
extern short SRcount;
extern Boolean hasPlot;
extern char tempString[256];
/*****************************************************************/
/* P R O T O T Y P E S
/*****************************************************************/
ListHandle CreateList ( WindowPtr theWindow,
short rowInt,
short colInt);
void IndexDeparse ( short i);
short do_save_file (WindowPtr wPtr, short do_sfput);
void close_the_window (WindowPtr wPtr);
OSErr get_c_filespec (short wd_refnum, long *dir_id, short *vol_refnum);
void CreateDefaultPreference(void);
void CreateNewFile ( OSType inCreator,
OSType inFileType,
ScriptCode inScriptCode /*= smSystemScript*/);
void SavePreferences (void);
short OpenDataFork (short inPrivileges);
long WriteDataFork ( const void *inBuffer,
long inByteCount);
/*****************************************************************/
/*****************************************************************/
/*
/* R O U T I N E S
/*
/*****************************************************************/
/*****************************************************************/
void file_seg() {} /* for reference in "UnloadSeg()" calls */
/********************** SetUpFile ************************/
/********************** SetUpFile ************************/
/********************** SetUpFile ************************/
void SetUpFile( Str255 *fn, short *refNum ) /* called from main() */
{
short io;
short i;
short notDone = 1;
long count,fcount;
Str255 sresult;
SFReply reply;
OSErr error,fsErr,iErr;
OSType folderType;
FSSpec *spec, theSpec;
Boolean tryToFindPrefs = TRUE;
Boolean createFolder = TRUE;
short foundVRefNum;
long foundDirID;
/*newCreated = FALSE;*/
//spec = &theSpec;
//fsErr = FindFolder(kOnSystemDisk, 'pref',kCreateFolder, &(spec->vRefNum), &(spec->parID) );
//fsErr = FSMakeFSSpec(spec->vRefNum, spec->parID, "\pDefault Prefs", spec);
//if(fsErr == fnfErr)
//{
// CreateDefaultPreference();
//}
count = sizeof(map);
while(notDone)
{
//if (tryToFindPrefs)
//{
// folderType = 'pref';
// iErr = FindFolder(refNum, folderType, createFolder, &foundVRefNum, &foundDirID);
//}
//else
//{
error = FSOpen(*fn, *refNum,&qRefNum); /* II-91, IV-109 */
if(error == fnfErr || error == bdNamErr)
{
error = Create( *fn, *refNum, 'INRS', 'INRC'); /* II-90, IV-112 */
error = FSOpen(*fn, *refNum,&qRefNum);
/*newCreated = TRUE;*/
InitMapData(fn,*refNum,qRefNum); /* in C14CalculatorData.c */
}
else
{
error = SetFPos(qRefNum,1,0); /* II-93, IV-110 */
error = FSRead(qRefNum,&count,&map); /* II-92, IV-109 */
if(map.regstat == 0 && map.memstat == 0)
{
map.memstat = 19;
map.regstat = 65 - map.memstat - map.memcom;
}
}
//}
/*error = FSClose(qRefNum);*/ /* II-94, IV-112 */
if(!error)
notDone = 0;
}
notDone = 1;
}
/*********************************************************/
/******************** SetUpLogFile ***********************/
/*********************************************************/
/************ called from calc_mousedown.c **********/
/*********************************************************/
OSErr SetUpLogFile (short selector,Str255 *fn,short *refNum,short *fRefNum)
{
//static char logState;
short io;
short i;
short notDone = 1;
short theRefNum;
long count,fcount;
Str255 sresult;
SFReply reply;
OSErr error;
OSErr err;
Boolean okay;
char *message;
//if(selector == 0)
//{
//theRefNum = *rRefNum;
//}
//else if (selector == 1)
//{
//theRefNum = sRefNum;
//}
okay = CheckOS (error = FSOpen(*fn, *refNum, &theRefNum));
/* II-91, IV-109 */
if(error == fnfErr || error == bdNamErr)
{
error = Create( *fn, *refNum, 'INRS', 'TEXT'); /* II-90, IV-112 */
error = FSOpen(*fn, *refNum,&theRefNum);
if(!error) ;
else
{
DebugStr("\pHello from FSOpen error, fnfErr or bdNamErr");
}
error = SetFPos(theRefNum,1,0);
if(!error) ;
else
{
switch(error)
{
case -39:
DebugStr("\pHello from SetFPos error, Attempt to position past the end-of-file");
break;
case -58:
DebugStr("\pHello from SetFPos error, External file system");
break;
case -38:
DebugStr("\pHello from SetFPos error, File not open");
break;
case -36:
DebugStr("\pHello from SetFPos error, I/O error");
break;
case -40:
DebugStr("\pHello from SetFPos error, Can't position to before start of file");
break;
case -51:
DebugStr("\pHello from SetFPos error, Bad fRefNum");
break;
}
}
#ifdef jcuNewOrigin
/* if(selector == 2)*/
/* {*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogNum(theRefNum,10); /* . »*/
/* DoLogNum(theRefNum,2); /* 2 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,7); /* CR »*/
/* */
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,1); /* 1 »*/
/* DoLogInit(theRefNum,7); /* CR »*/
/* */
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogNum(theRefNum,10); /* . »*/
/* DoLogNum(theRefNum,2); /* 2 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,2); /* 2 »*/
/* DoLogInit(theRefNum,7); /* CR »*/
/* */
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,7); /* CR »*/
/* */
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,0); /* 0 »*/
/* DoLogNum(theRefNum,10); /* . »*/
/* DoLogNum(theRefNum,2); /* 2 »*/
/* DoLogInit(theRefNum,5); /* Tab »*/
/* DoLogNum(theRefNum,3); /* 3 »*/
/* DoLogInit(theRefNum,7); /* CR »*/
/* }*/
#else
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,10); /* . */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,9); /* 9 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,7); /* CR */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,1); /* 1 */
DoLogInit(theRefNum,7); /* CR */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,1); /* 1 */
DoLogNum(theRefNum,5); /* 5 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,10); /* . */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,2); /* 2 */
DoLogInit(theRefNum,7); /* CR */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,7); /* CR */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,10); /* . */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,0); /* 0 */
DoLogNum(theRefNum,2); /* 2 */
DoLogInit(theRefNum,5); /* Tab */
DoLogNum(theRefNum,3); /* 3 */
DoLogInit(theRefNum,7); /* CR */
#endif
//logState = '1';
/* 1 is Red */
/* 2 is Green */
/* 3 is Blue */
/* 4 is White */
/* 5 is Tab */
/* 6 is Space */
/* 7 is CR */
/*newCreated = TRUE;*/
//InitMapData(fn,*refNum,rRefNum); /* in C14CalculatorData.c */
}
if(error == opWrErr)
{
err = FSClose(theRefNum); /* II-94, IV-112 */
if(!err);
else
{
;
}
//DebugStr("\pHello from FSOpen error, file is already open with write permission");
}
else if(okay)
{
//error = SetFPos(theRefNum,1,0); /* II-93, IV-110 */
SetFPos(theRefNum,2,0); /* II-93, IV-110 */ /* 2 means from end */
}
*fRefNum = theRefNum;
/* if(selector == 0)*/
/* {*/
/* rRefNum = theRefNum;*/
/* }*/
/* else if (selector == 1)*/
/* {*/
/* sRefNum = theRefNum;*/
/* }*/
return(error);
}
/*********************************************************/
/**************** End of SetUpLogFile ********************/
/*********************************************************/
/*void CreateDefaultPreference(void)*/
/*{*/
/* OSType mCreator = 'INRS';*/
/* Preference mPrefs;*/
/* */
/* Handle prefs;*/
/* */
/* // If the preference file does not exist, then load the*/
/* // 'pref' resource in the application's resource fork.*/
/* // Use that as the default data for a new preference file.*/
/* /*prefFile->CreateNewFile(mCreator, 'pref', -1);» // original*/
/* */
/* mMacFileSpec.vRefNum = 0; // ??? Is this a good default for*/
/* mMacFileSpec.parID = 0; // a File Spec ???*/
/* mMacFileSpec.name[0] = 0;*/
/**/
/* */
/* CreateNewFile(mCreator, 'pref', -1); // new*/
/* prefs = GetResource('pref', 128);*/
/* mPrefs = **(Preference**)prefs;*/
/* ReleaseResource(prefs);*/
/* SavePreferences();*/
/*}*/
/*void CreateNewFile(*/
/* OSType inCreator,*/
/* OSType inFileType,*/
/* ScriptCode inScriptCode)*/
/*{*/
/* FSpCreateResFile(&mMacFileSpec, inCreator, inFileType, inScriptCode);*/
/* //ThrowIfResError_();*/
/*}*/
//----------------------------------
// SavePreferences
// Write data to file
//----------------------------------
/*void SavePreferences()*/
/*{*/
/* OpenDataFork(fsCurPerm);*/
/* WriteDataFork(&mPrefs, sizeof(Preference));*/
/* CloseDataFork();*/
/*}*/
/*short OpenDataFork(short inPrivileges)*/
/*{*/
/* OSErr err;*/
/* */
/* err = FSpOpenDF(&mMacFileSpec, inPrivileges, &mDataForkRefNum);*/
/* if(err != noErr)*/
/* {*/
/* mDataForkRefNum = refNum_Undefined;*/
/* }*/
/*}*/
/*long WriteDataFork(*/
/* const void *inBuffer,*/
/* long inByteCount)*/
/*{*/
/* long bytesWritten = inByteCount;*/
/* OSErr err;*/
/* */
/* err = SetFPos(mDataForkRefNum, fsFromStart, 0);*/
/*}*/
void save_window(WindowPtr wPtr)
{
short user_response = 0;
char w_title[255];
WObjsHandle w_objs_hndl;
short the_object;
/***
First, check if the window pointer is a valid one for the application.
If so, check to see if the window has been written to but not saved.
***/
if(!one_of_mine(wPtr)) return;
w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
if(w_objs_hndl == NIL) return;
/*w_objs_hndl=(WObjs**)GetWRefCon(wPtr);*/
the_object = (**w_objs_hndl).paletteSetting;
if(the_object == PLOT_OBJ)
{
hasPlot = FALSE; /* reset hasPlot */
/*DeleteMenu( PLOT_MENU_ID );*/
DeleteMenu( PlotID );
DrawMenuBar();
}
if((**w_objs_hndl).dirty)
{
GetWTitle(wPtr, (StringPtr)w_title);
ParamText((StringPtr)w_title, "\p", "\p", "\p");
#ifdef powerc
user_response = CautionAlert(SAVE_CHANGES, (UniversalProcPtr)NIL);
#else
user_response = CautionAlert(SAVE_CHANGES, NIL);
#endif /* powerc */
switch(user_response)
{
case SAVE_YES:
#ifdef powerc
StopAlert (UNDER_CONSTRUCTION, (UniversalProcPtr)NIL);
#else
StopAlert (UNDER_CONSTRUCTION, NIL);
#endif /* powerc */
if(do_save_file(wPtr, DO_SAVE) == SUCCESS)
close_the_window(wPtr);
else
gDone = FALSE;
break;
case SAVE_NO:
close_the_window(wPtr);
break;
case SAVE_CANCEL:
gDone = false; /* if "Cancel", stop any "quit" operation */
break;
} /* end of switch */
} /* end of if(**w_objs_hndl).dirty) */
else close_the_window(wPtr);
} /* end of "save_window()" */
void close_the_window(WindowPtr wPtr)
{
short n;
WObjsHandle w_objs_hndl;
/************* If it isn't one of our windows, skip it! ******************/
if( !(n = one_of_mine(wPtr)) ) return;
/***** Else dispose the controls and window, and clear our list **********/
w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
if(w_objs_hndl != NIL)
{
HLock((Handle)w_objs_hndl);
/* look at this */
if((**w_objs_hndl).prInfoHndl) DisposHandle((Handle)(**w_objs_hndl).prInfoHndl);
DisposHandle((Handle)w_objs_hndl);
}
DisposeWindow(gMy_windows[n]); /* also does a "KillControls()" */
gMy_windows[n] = NIL;
} /* end of close_the_window() */
short do_save_file(WindowPtr wPtr,short do_what)
//WindowPtr wPtr;
//short do_what;
{
short file_ref_num, wd_refnum, vol_refnum;
Point where;
long count, dir_id;
OSErr error_code;
OSType the_creator, our_type;
char local_str[256], window_name[256];
char *srce_ptr, *dest_ptr;
char **dlog_str_hndl;
Ptr data_ptr;
WObjsHandle w_objs_hndl;
THPrint pr_info_hndl;
/********* If our window data structure is absent, don't even start this! **********/
w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
if(w_objs_hndl == NIL) return(FILE_ERROR);
/************* Set up some initial values and lock our window data **********/
count = 0;
the_creator = CREATOR_CODE; /* our "creator type" */
our_type = TYPE_CODE; /* our "file type" */
SetPt(&where, 100, 80); /* where to put the file dialog boxes */
MoveHHi((Handle)w_objs_hndl);
HLock ((Handle)w_objs_hndl);
/**
Note:
The "findFile" element of the window data structure is of type SFReply.
The structure of the SFReply record is as follows:
typedef struct
{
Boolean good;
Boolean copy;
fType OSType;
short vrefNum;
short version;
char fName[255];
}SFReply;
**/
/********* Build up the dialog prompt: "Save (filename) as:" **********/
/**
Use strings save in 'STR " resources named "Save" and "As",
and the file name from the "findFile" item in the window info record.
**/
local_str[0] = 0;
dest_ptr = local_str;
dlog_str_hndl = (char**)GetString(SAVE_ID);
MoveHHi(dlog_str_hndl);
HLock (dlog_str_hndl);
srce_ptr = (char*)*dlog_str_hndl;
cat_strings(srce_ptr, dest_ptr, 255);
HUnlock(dlog_str_hndl);
GetWTitle(wPtr, (StringPtr)window_name);
srce_ptr = window_name;
cat_strings(srce_ptr, dest_ptr, 255);
dlog_str_hndl = (char**)GetString(AS_ID);
MoveHHi(dlog_str_hndl);
HLock (dlog_str_hndl);
srce_ptr = (char*)*dlog_str_hndl;
cat_strings(srce_ptr, dest_ptr, 255);
HUnlock(dlog_str_hndl);
/***
If we need to specify a file name, do SFPut thing...
***/
if( (do_what == DO_SFPUT) ||
((**w_objs_hndl).hasRealName == FALSE) )
{
InitCursor();
#ifdef powerc
SFPutFile( where,
(StringPtr)local_str,
(StringPtr)window_name,
(UniversalProcPtr)NIL,
&(**w_objs_hndl).findFile);
#else
SFPutFile( where,
(StringPtr)local_str,
(StringPtr)window_name,
NIL,
&(**w_objs_hndl).findFile);
#endif
/***
If the user cancelled the operation, restore the window name
***/
if ((**w_objs_hndl).findFile.good == FALSE)
{
dest_ptr = (char*)((**w_objs_hndl).findFile.fName);
(**w_objs_hndl).findFile.fName[0] = 0;
cat_strings(window_name, dest_ptr, 255);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
/***
Otherwise, get the vol_refnum and create the file
***/
else
{
wd_refnum = (**w_objs_hndl).findFile.vRefNum;
error_code = get_c_filespec(wd_refnum, &dir_id, &vol_refnum);
if(error_code != noErr) return(FILE_ERROR);
error_code = Create(
(**w_objs_hndl).findFile.fName,
wd_refnum,
the_creator,
our_type);
if( (error_code != noErr) &&
(error_code != dupFNErr) )
{
#ifdef powerc
StopAlert(CREATE_ERR, (UniversalProcPtr)NIL);
#else
StopAlert(CREATE_ERR, NIL);
#endif /* powerc */
HUnlock((Handle)w_objs_hndl);
return(CREATE_ERR);
}
else (**w_objs_hndl).hasRealName = TRUE;
}
}
/************* Save the data in the specified file **********/
/*** a) open the file ***/
if( (do_what == DO_SFPUT) ||
(do_what == DO_SAVE) )
{
wd_refnum = (**w_objs_hndl).findFile.vRefNum;
error_code = get_c_filespec(wd_refnum, &dir_id, &vol_refnum);
if(error_code != noErr) return(FILE_ERROR);
error_code = FSOpen(
(**w_objs_hndl).findFile.fName,
wd_refnum,
&file_ref_num);
if ((error_code != noErr) || (file_ref_num == 0) )
{
StopAlert(OPEN_ERR,0);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
/*** b) check to see that there's disc space ***/
count = sizeof(fileDataRecord);
error_code = SetEOF(file_ref_num, count);
if (error_code != noErr)
{
StopAlert(WRITE_ERR,0);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
/************* c) write the data to the file **********/
/***
Note: we are only writing that portion of the WObjs Record
that includes the object-count and the objects themselves.
We have intentionally positioned these items together at
the end (bottom) of the definition of the WObjsRecord.
Thus, by pointing to (**w_objs_hndl).vDocLimit and
supplying a byte count equal to the size of this portion
of the data structure, we can write just the data we want
to the file without having to gather it together from
separate places into a single block before writing.
***/
/***
Note: before writing the data out, copy the print info record from
the heap into the window objects record.
***/
//pr_info_hndl = (**w_objs_hndl).prInfoHndl;
//(**w_objs_hndl).printInfo = **pr_info_hndl;
data_ptr = (Ptr)(&(**w_objs_hndl).vDocLimit);
error_code = FSWrite(file_ref_num, &count, data_ptr);
if (error_code != noErr)
{
StopAlert(WRITE_ERR,0);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
/********* d) close the file **********/
error_code = FSClose(file_ref_num);
if (error_code != noErr)
{
StopAlert(WRITE_ERR,0);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
/************* e) post the data to the disc **********/
error_code = FlushVol(0, vol_refnum);
if (error_code != noErr)
{
StopAlert(WRITE_ERR,0);
HUnlock((Handle)w_objs_hndl);
return(CANCELED);
}
} /* end of do_what = SFPUT || do_what == DO_SAVE */
/***
we made it!
***/
HUnlock((Handle)w_objs_hndl);
(**w_objs_hndl).dirty = FALSE;
return(SUCCESS);
} /* end of do_save_file() */
OSErr get_c_filespec(short wd_refnum,long *dir_id,short *vol_refnum)
{
WDPBRec pb_rec;
OSErr err;
pb_rec.ioNamePtr = NIL;
pb_rec.ioWDProcID = 0L;
pb_rec.ioWDIndex = 0;
pb_rec.ioVRefNum = wd_refnum;
err = PBGetWDInfo(&pb_rec, FALSE);
if(err == noErr)
{
*dir_id = pb_rec.ioWDDirID;
*vol_refnum = pb_rec.ioWDVRefNum;
}
return(err);
}